package com.nb.service.impl;

import com.mybatisflex.core.query.QueryWrapper;
import com.nb.entity.Lawyer;
import com.nb.entity.User;
import com.nb.mapper.LawyerMapper;
import com.nb.mapper.RoleMapper;
import com.nb.mapper.UserMapper;
import com.nb.service.LawyerService;
import com.nb.vo.LawyerVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class LawyerServiceImpl implements LawyerService {

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private LawyerMapper lawyerMapper;

    @Override
    public List<LawyerVO> getLawyerList() {

        List<Lawyer> lawyerList = lawyerMapper.selectAll();
        List<LawyerVO> voList = new ArrayList<>();
        for (Lawyer lawyer : lawyerList) {
            User user = userMapper.selectOneById(lawyer.getUserId());
            LawyerVO vo = new LawyerVO();
            vo.setLawyerId(lawyer.getId());
            vo.setName(user.getRealName());
            voList.add(vo);
        }
        return voList;
    }

}